package br.com.sistemavendas.teste;

import java.util.Date;

import org.hibernate.Transaction;
import org.hibernate.classic.Session;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import br.com.sistemavendas.dao.ClienteRN;
import br.com.sistemavendas.dao.HibernateUtil;
import br.com.sistemavendas.entidade.Cliente;


public class ClienteTest {
	
	private static Session sessao;
	private static Transaction transaction;

	@BeforeClass
	public static void abreConexao() {
		sessao = HibernateUtil.getSession().getCurrentSession();
		transaction = sessao.beginTransaction();
		
	}
	
	@AfterClass
	public static void fechaConexao() {
		transaction.commit();
	}

	@Test
	public void salvarCliente(){
		
		Cliente c1 = new Cliente();
		
		c1.setNome("lilian costa");
		c1.setCpf("05880478300");
		c1.setEmail("lilian_costa@Hotmail.com");
		c1.setRenda(4000);
		c1.setDataCadastro(new Date());
		c1.setEndereco("rua bias mendes, 618");
		
		ClienteRN clienteRn = new ClienteRN();
		
		clienteRn.salvar(c1);
		
	}
	
}
